layui.config({
    base: '/cropper/layui_modules/' //你存放新模块的目录，注意，不是layui的模块目录
}).use('cropperUpload'); //加载入口

layui.use(['element','form','table','layer','laydate','layedit','cropperUpload'],function () {
    var element = layui.element;
    var form=layui.form;
    var table=layui.table;
    var layer=layui.layer;
    var laydate=layui.laydate;
    var layedit=layui.layedit;
    var cropperUpload = layui.cropperUpload;

    //表单封面裁剪图片组件
    formCoverUpload = cropperUpload.init({
        select : "#formCoverUpload",
        aspectRatio : NaN,
        imgWidth : 269,
        imgHeight : 69,
        formDataId : "#blogForm",
        success : function(base64Img,blog,that) { //base64Img  base64格式图片    blog  二进制图
            $("#showImg").attr("src", base64Img)
        }
    })

    layedit.set({
        uploadImage: {
            url: '/admin/setting/uploadImage' //接口url
            ,type: 'POST' //默认post
        }
    });

    //初始化富文本编辑器
    editIndex = layedit.build('content');

    //提交事件
    form.on("submit(doSubmit)",function (data) {
        console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
        console.log(data.form) //被执行提交的form对象，一般在存在form标签时才会返回
        console.log($("#settingForm").serializeJson()) //当前容器的全部表单字段，名值对形式：{name: value}
        if(layedit.getText(editIndex)==""){
            layer.msg("系统公告不能为空");
            return false;
        }
        layedit.sync(editIndex);
        formCoverUpload.ajaxPost("/admin/setting/updateSetting", function(res) {
            layer.msg(res.content)
            if(res.success){

            }
        },$("#settingForm").serializeJson())

        return false;
    })



});